package com.chenjiajin.web.controller;

import com.chenjiajin.web.anno.NotControllerResponseAdvice;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class AopController {

    // http://localhost/advice?str=111
    @GetMapping("/advice")
    public String advice(String str) {
        System.out.println("advice: " + str);
        //int a = 1 / 0;
        return "advice";
    }

    // http://localhost/advice2?str=222
    @NotControllerResponseAdvice   // 不封装返回值
    @RequestMapping("/advice2")
    public String advice2(String str) {
        System.out.println("advice2: " + str);
        //int a = 1 / 0;  // 当异常的时候 仍然执行统一异常处理
        return "advice2";
    }


}